/**
 * Copyright 2007 Luke Pillow
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.orsomethinglikethat.hinge.asgen;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;

import com.sun.mirror.apt.AnnotationProcessor;
import com.sun.mirror.apt.AnnotationProcessorEnvironment;
import com.sun.mirror.apt.AnnotationProcessorFactory;
import com.sun.mirror.apt.AnnotationProcessors;
import com.sun.mirror.declaration.AnnotationTypeDeclaration;

/**
 * @author lpillow
 */
public class AS3ClassAnnotationProcessorFactory implements AnnotationProcessorFactory
{

    private static final Collection<String> supportedAnnotations = Collections.singletonList( "com.orsomethinglikethat.hinge.asgen.AS3Class" );
    // private static final Collection<String> supportedAnnotations =
    // Collections.unmodifiableCollection( Arrays.asList( "*" ) );

    // Supported options
    private static final Collection<String> supportedOptions;
    static final String USER_CLASSES = "user_classes_home";
    
    static
    {
        supportedOptions = new ArrayList<String>();
        supportedOptions.add( USER_CLASSES );
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.sun.mirror.apt.AnnotationProcessorFactory#getProcessorFor(java.util.Set,
     *      com.sun.mirror.apt.AnnotationProcessorEnvironment)
     */
    public AnnotationProcessor getProcessorFor( Set<AnnotationTypeDeclaration> declarations, AnnotationProcessorEnvironment env )
    {
        AnnotationProcessor processor = AnnotationProcessors.NO_OP;

        if ( declarations.isEmpty() == false )
        {
            processor = new AS3ClassAnnotationProcessor( env );
        }

        return processor;
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.sun.mirror.apt.AnnotationProcessorFactory#supportedAnnotationTypes()
     */
    public Collection<String> supportedAnnotationTypes()
    {
        return AS3ClassAnnotationProcessorFactory.supportedAnnotations;
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.sun.mirror.apt.AnnotationProcessorFactory#supportedOptions()
     */
    public Collection<String> supportedOptions()
    {
        return AS3ClassAnnotationProcessorFactory.supportedOptions;
    }

}
